﻿using Blog.IRepository;
using EiiFBlog.IServer;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace EiiFBlog.Service
{
    public class BaseService<Tentity> : IBaseService<Tentity> where Tentity : class, new()
    {
        protected IBaseRepository<Tentity> baseRepository;

        public async Task<bool> Create(Tentity tentity)
        {
            return await baseRepository.Create(tentity);
        }

        public async Task<bool> Delete(int Id)
        {
            return await baseRepository.Delete(Id);
        }

        public async Task<bool> Edit(Tentity tentity)
        {
            return await baseRepository.Edit(tentity);
        }

        public async Task<Tentity> Find(int Id)
        {
            return await baseRepository.Find(Id);
        }

        public async Task<Tentity> Find(Expression<Func<Tentity, bool>> func)
        {
            return await baseRepository.Find(func);
        }

        public async Task<List<Tentity>> Query()
        {
            return await baseRepository.Query();
        }

        public async Task<List<Tentity>> Query(Expression<Func<Tentity, bool>> func)
        {
            return await baseRepository.Query(func);
        }

        public async Task<List<Tentity>> Query(int page, int size, RefAsync<int> total)
        {
            return await baseRepository.Query(page, size, total);
        }

        public async Task<List<Tentity>> Query(Expression<Func<Tentity, bool>> func, int page, int size, RefAsync<int> total)
        {
            return await baseRepository.Query(func, page, size, total);
        }
    }
}
